package com.jgp.config;

import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 项目   jgp-cloud-parent
 * 作者   loufei
 * 时间   2020-03-18
 */
@Configuration
@ConditionalOnProperty(prefix = "spring.application", name = "name", matchIfMissing = true)
public class PrometheusConfiguration {
    
    @Value("${spring.application.name}")
    private String applicationName;
    
    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer(
            @Value("${spring.application.name}") String applicationName) {
        return (registry) -> registry.config().commonTags("application", applicationName);
    }
}
